<?php

include('include/header.php');

if ($_SESSION['user'] != 'w1r0x') header("Location: /");

if (isset($_GET['id']))
{
   $mysql = mysql_connect("localhost", "root", "kGbN85Z");
   mysql_query("USE ftp;");

   $res = mysql_query("SELECT `filename` FROM `films` WHERE `id`='".mysql_real_escape_string($_GET['id'])."';");
   if(!mysql_num_rows($res)) die();
   $row = mysql_fetch_row($res);
   echo $row[0];
   mysql_query("DELETE FROM `films` WHERE `id`=".mysql_real_escape_string($_GET['id']).";");
   mysql_query("DELETE FROM `films_raiting` WHERE `film_id`=".mysql_real_escape_string($_GET['id']).";");
   mysql_query("DELETE FROM `films_genre` WHERE `film_id`=".mysql_real_escape_string($_GET['id']).";");
   mysql_query("DELETE FROM `watched_films` WHERE `film_id`=".mysql_real_escape_string($_GET['id']).";");
   mysql_close($mysql);

   unlink("/mnt/ftp/hd0/Фильмы/".$row[0]);
   echo "Фильм удален";
}
else header("Location: /");


include('include/footer.php');

?>
